package com.me.Design;

import java.util.Scanner;

import com.me.common.enums.PeopleType;
import com.me.dao.base.BasePeople;
import com.me.dao.base.PeopleModel;
import com.me.dao.people.PeopleDao;
import com.me.dao.people.impl.DbPeopleDaoImpl;
import com.me.dao.people.impl.LyPeopleDaoImpl;
import com.me.dao.util.DesignFactory;

/**
 * 功能：工厂模式
 * 简单的通过特定参数确认子类进行操作
 *				---- DbPeopleDaoImpl() 实现getPeople()
 *PeopleDao:  getPeople()
 *				---- LyPeopleDaoImpl() 实现getPeople()
 *
 * @author：dongshibo(F_baisi)
 * @create：2019/1/23/023 16:10
 * @version：2019 Version：1.0
 * @company：老屋新房 Created with IntelliJ IDEA
 */
public class FactoryDesignTest {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String name = scanner.next();
		if(!PeopleType.Contains(name)){
			System.out.println("资源未找到");
			return;
		}
		//不同参数获取不同的实现
		PeopleDao peopleDao = null;
		switch (PeopleType.getByValue(name)){
			case DABIN:
				peopleDao = DesignFactory.getDbPeopleDao();
				break;
			case LIUYANG:
				peopleDao = DesignFactory.getLyPeopleDao();
				break;
		}
		System.out.println(peopleDao.getPeople());
		//父类调取子类中的实现
		PeopleDao peopleModel = new DbPeopleDaoImpl();
		PeopleModel people = peopleModel.getPeople();
		System.out.println(people);
		System.out.println(peopleModel instanceof BasePeople);
		System.out.println(peopleModel instanceof LyPeopleDaoImpl);
	}
}
